package com.it.schoolbookshop_back.enums;

/**
 * 订单状态枚举类
 */
public enum OrderStatusEnum {
    /**
     * 进行中
     */
    PENDING("pending", "进行中"),
    
    /**
     * 已完成
     */
    COMPLETED("completed", "已完成"),
    
    /**
     * 已取消
     */
    CANCELLED("cancelled", "已取消");
    
    private final String status;
    private final String description;
    
    OrderStatusEnum(String status, String description) {
        this.status = status;
        this.description = description;
    }
    
    public String getStatus() {
        return status;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据状态码获取枚举
     * @param status 状态码
     * @return 订单状态枚举
     */
    public static OrderStatusEnum getByStatus(String status) {
        for (OrderStatusEnum orderStatus : OrderStatusEnum.values()) {
            if (orderStatus.getStatus().equals(status)) {
                return orderStatus;
            }
        }
        return null;
    }
}
